package day05;

import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = new int[10];
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            arr[i] = (int) (Math.random() * 100 + 1);
        }
        System.out.println(Arrays.toString(arr));

        int max = arr[0];
        for (int i = 1; i < n; i++){
            if (arr[i] > max){
                max = arr[i];
            }
        }
        System.out.println(max);

        arr = Arrays.copyOf(arr,arr.length + 1);//扩容
        arr[n] = max;//最大值赋值到数组最后一位
        System.out.println(Arrays.toString(arr));


        int[] arr2 = new int[10];
        System.arraycopy(arr,0,arr2,1,7);
        System.out.println(Arrays.toString(arr2));

        int[] arr3 = Arrays.copyOf(arr,5);
        System.out.println(Arrays.toString(arr3));


    }
}
